package com.yichen.entity;

import lombok.Getter;

/**
 * @Classname JavaTypeEnum
 * @Description
 * @Author caozhenhao001
 * @Date 2024/6/6
 * @Version
 */
@Getter
public enum JavaTypeEnum {
    STRING("String", "字符串"),
    INTEGER("Integer", "整型"),
    DOUBLE("Double", "浮点型"),
    BOOLEAN("Boolean", "布尔型"),
    SHORT("Short", "短整型"),
    BYTE("Byte", "字节"),
    LONG("Long", "长整型"),
    FLOAT("Float", "浮点型"),
    CHARACTER("Character", "字符"),
    DATE("java.util.Date", "日期"),
    OBJECT("Object", "对象");

    private final String name;
    private final String code;

    JavaTypeEnum(String code, String name) {
        this.name = name;
        this.code = code;
    }

    public static JavaTypeEnum create(String type) {
        for (JavaTypeEnum javaTypeEnum : JavaTypeEnum.values()) {
            if (javaTypeEnum.code.equals(type)) {
                return javaTypeEnum;
            }
        }
        return OBJECT;
    }
}
